#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10, M = 1e6 + 10;
int cnt[M];
int a[N];
int n;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		scanf("%d", &n);
		for (int i = 0; i <= 2 * n; i++) {
			cnt[i] = 0;
		}
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			a[i] ^= a[i - 1];
		}
		cnt[0]++;
		LL ans = 1ll * n * (n + 1) / 2;
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j * j <= 2 * n; j++) {
				ans -= cnt[a[i] ^ (j * j)];
			}
			cnt[a[i]]++;
		}
		cout << ans << endl;
	}
	return 0;
}